package loengud.w09;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;

class ColoredHelloWorldCanvas extends Canvas {
	Color textColor; // Color in which "Hello World" is displayed.
	Font textFont; // The font in which the message is displayed.

	ColoredHelloWorldCanvas() { // Constructor
		setBackground(Color.white);
		textColor = Color.red;
		textFont = new Font("Serif", Font.BOLD, 24);
	}

	public void paint(Graphics g) {
		// Show the message
		g.setColor(textColor);
		g.setFont(textFont);
		g.drawString("Hello World!", 20, 40);
	}

	void setTextColor(Color color) {
		// Set the text color and tell the system to repaint the canvas.
		textColor = color;
		repaint();
	}
} // -class
